<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>        
        <title>#{i18n['listachave.head.title']}</title>
    </h:head>
    <h:body>
        <ui:composition template="template.xhtml">
            <ui:define name="conteudo">
                <p:panel header="#{i18n['listachave.panel.header']}">
                    <h:form>
                        <p:dataTable value="#{chaveBean.chaves}" var="umChave"
                                     emptyMessage="#{i18n['listachave.dataTable.emptyMessage']}">
                            <p:column headerText="#{i18n['listachave.dataTable.column.sigla.headerText']}">
                                <h:outputText value="#{umChave.sigla}"/>
                            </p:column>
                            <p:column headerText="#{i18n['listachave.dataTable.column.restrito.headerText']}">
                                <h:outputText value="#{funcoesGeraisBean.getBooleanToString(umChave.restrito)}"/>
                            </p:column>
                            
                            <p:column headerText="#{i18n['generico.dataTable.column.acoes.title']}">
                                <p:commandButton image="ui-icon ui-icon-pencil" title="#{i18n['generico.dataTable.column.button.editar.title']}"
                                                 ajax="false" action="#{chaveBean.editar(umChave)}"/>
                                <p:commandButton image="ui-icon ui-icon-close" title="#{i18n['generico.dataTable.column.button.excluir.title']}"
                                                 ajax="true" onclick="dlgConfExcluir.show();">
                                    <f:setPropertyActionListener value="#{umChave}"
                                                                 target="#{chaveBean.chave}"/>
                                </p:commandButton>
                            </p:column>                
                        </p:dataTable>
                        <p:outputPanel layout="block" 
                                       style="margin: auto; width:40%">

                            <p:commandButton value="#{i18n['listachave.button.novachave.value']}" ajax="false" action="#{chaveBean.novo()}"/>
                        </p:outputPanel>                
                        

                        <p:confirmDialog message="#{i18n['listachave.confirmDialog.message']}" width="400"
                                         header="#{i18n['generico.dataTable.column.button.excluir.title']}" severity="alert" widgetVar="dlgConfExcluir">
                            <p:commandButton value="#{i18n['generico.button.sim.label']}" ajax="false"
                                             action="#{chaveBean.excluir()}" />
                            <p:commandButton value="#{i18n['generico.button.nao.label']}" type="button"
                                             onclick="dlgConfExcluir.hide()" />
                        </p:confirmDialog>
                    </h:form>
                </p:panel>
            </ui:define>
        </ui:composition>                  
    </h:body>
</html>

